<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<script type="text/javascript">
	$(function() {
		var cProName = '';
		var cNum = 0;
		var cCode = 0;
		$('#moduls_fun_doDeterPer_datagrid').datagrid({
			url : '${pageContext.request.contextPath}/detContentAction!querySDC.action?userId=' + moduls_deterPerson_doDeterPerFun_userId,
			fit : true,
			border : false,
			checkOnSelect : false,
			selectOnCheck : false,
			collapsible : true,
			idField : 'contentId',
			nowrap : false,
			columns : [ [ {
				title : '测评项目ID',
				field : 'contentId',
				width : 50,
				rowspan : 2,
				hidden : true
			}, {
				title : '序号',
				field : 'num',
				width : 30,
				align : 'center',
				rowspan : 2,
				formatter : function(value, row, index) {
					if (cProName === row.projectName) {
						row.num = cNum;
						return cNum;
					} else {
						cProName = row.projectName;
						cNum += 1;
						row.num = cNum;
						return cNum;
					}
				}
			}, {
				title : '测评项目',
				field : 'projectName',
				width : 85,
				align : 'center',
				rowspan : 2
			}, {
				title : '编号',
				field : 'code',
				width : 30,
				align : 'center',
				rowspan : 2,
				formatter : function(value, row, index) {
					cCode += 1;
					return cCode;
				}
			}, {
				title : '测评内容',
				field : 'detContent',
				width : 390,
				align : 'center',
				formatter : function(value, row, index) {
					return '<div align="left">' + value + '</div>';
				},
				rowspan : 2
			}, {
				title : '测评选项',
				align : 'center',
				colspan : 4
			} ], [ {
				title : '优',
				field : 'n1',
				align : 'center',
				width : 30,
				formatter : function(value, row, index) {
					return '<input type="radio" id="' + row.contentId + '" name="' + row.contentId + '" value="优"';
				}
			}, {
				title : '良',
				field : 'n2',
				align : 'center',
				width : 30,
				formatter : function(value, row, index) {
					return '<input type="radio" id="' + row.contentId + '" name="' + row.contentId + '" value="良"';
				}
			}, {
				title : '中',
				field : 'n3',
				align : 'center',
				width : 30,
				formatter : function(value, row, index) {
					return '<input type="radio" id="' + row.contentId + '" name="' + row.contentId + '" value="中"';
				}
			}, {
				title : '差',
				field : 'n4',
				align : 'center',
				width : 30,
				formatter : function(value, row, index) {
					return '<input type="radio" id="' + row.contentId + '" name="' + row.contentId + '" value="差"';
				}
			} ] ],
			onLoadSuccess : function() {
				$(this).datagrid("autoMergeCells", [ 'num', 'projectName' ]);
			}
		});

		$.ajax({
			type : 'POST',
			url : '${pageContext.request.contextPath}/deterPersonAction!getDeterPerInfo.action',
			data : {
				posId : moduls_deterPerson_doDeterPerFun_id
			},
			cache : false,
			dataType : 'JSON',
			success : function(r) {
				var tempStr = '';
				for ( var i = 0; i < r.duty.length; i++) {
					tempStr += (i + 1) + "、" + r.duty[i].pdCont + "<br />";
				}
				$("#doDeterPer_duty").html(tempStr);
			}
		});

		$("#moduls_fun_doDeterPer_psCont").click(function() {
			if ($("#moduls_fun_doDeterPer_psCont").val() == "对Ta的建议........") {
				$("#moduls_fun_doDeterPer_psCont").val("");
			}
		});
		$("#moduls_fun_doDeterPer_psCont").blur(function() {
			if ($("#moduls_fun_doDeterPer_psCont").val() == "") {
				$("#moduls_fun_doDeterPer_psCont").val("对Ta的建议........");
			}
		});
	});

	function moduls_deterPerson_doDeter() {
		var list = [];
		var contRes;
		var item = $("#moduls_fun_doDeterPer_layout_center :radio:checked");
		var rows = $("#moduls_fun_doDeterPer_datagrid").datagrid('getRows');

		if (item.length == rows.length) {
			for ( var i = 0; i < item.length; i++) {
				contRes = new Object();
				contRes.userId = moduls_deterPerson_doDeterPerFun_userId;
				contRes.contentId = item[i].name;
				contRes.detproOpt = item[i].value;
				list.push(contRes);
			}

			////console.info($.toJSON(list));
			var d = $(this).closest('.window-body');

			var psCont = $("#moduls_fun_doDeterPer_psCont").val();
			var detPerId = $("#doDeterPer_detPerId").val();
			if(psCont === '对Ta的建议........') {
				psCont = '';
			}
			$.ajax({
				type : 'POST',
				url : '${pageContext.request.contextPath}/deterPersonAction!doDeter.action',
				data : {
					jsonStr : $.toJSON(list),
					psCont : psCont,
					userId : detPerId
				},
				cache : false,
				dataType : 'JSON',
				success : function(r) {
					//console.info(r.success);
					if (r.success) {
						moduls_deterPerson_doDeterPerFun_div.dialog('destroy');
					}
					$.messager.show({
						msg : r.msg,
						title : '提示'
					});
				}
			});

			//console.info(psCont);
		} else {
			$.messager.show({
				msg : '您还没测评完所有项目！',
				title : '提示'
			});
		}

	}
</script>
<div id="moduls_fun_doDeterPer_layout" class="easyui-layout" data-options="fit:true">

	<div data-options="region:'north', title:'Ta的信息', border:false" style="height: 200px; background-color: #EFEFEF;">
		<div style="height: 100%;">
		<input id="doDeterPer_detPerId" name="detPerId" style="display: none;" hidden="true"/>
			<table style="width: 460; border: 0xp;">
				<tr>
					<td width="100" rowspan="4"><img id="fun_doDeterPer_img" src="" width="108" height="129" /></td>
					<td width="100" height="25" align="center">姓名:</td>
					<td width="150" height="25"><samp id="doDeterPer_username"></samp></td>
					<td height="25" align="center"></td>
					<td height="25"></td>
				</tr>
				<tr>
					<td height="25" align="center">岗位:</td>
					<td height="25"><samp id="doDeterPer_posId"></samp></td>
					<td height="25" align="center"></td>
					<td height="25"></td>
				</tr>
				<tr>
					<td height="25" align="center">上级:</td>
					<td height="25"><samp id="doDeterPer_personSup"></samp></td>
					<td height="25" align="center"></td>
					<td height="25"></td>
				</tr>
				<tr>
					<td height="25" align="center">下级:</td>
					<td height="25"><samp id="doDeterPer_personSub"></samp></td>
					<td width="100" height="25" align="center">责任对象:</td>
					<td width="150" height="25"><samp id="doDeterPer_dutyObj"></samp></td>
				</tr>
			</table>
			<fieldset>
				<legend>Ta的职责</legend>
				<samp id="doDeterPer_duty"></samp>
			</fieldset>
		</div>
	</div>
	<div id="moduls_fun_doDeterPer_layout_center" data-options="region:'center',border:false, title:'对Ta的测评'">
		<table id="moduls_fun_doDeterPer_datagrid"></table>
	</div>
	<div data-options="region:'south',border:false" style="height: 70px; overflow: hidden;">
		<textarea name="psCont" id="moduls_fun_doDeterPer_psCont" style="width:100%; height:50px; resize: none; font-size: 12px; font-weight: normal;" class="easyui-validatebox" data-options="required:false">对Ta的建议........</textarea>
	</div>
</div>
